using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
using KPIS.GERP.Models.Class;

namespace KPIS.GERP.Models.HRM
{
	[Table("hrm_ps_commands")]
    public class PsCommand
    {
        public PsCommand()
        {
            CmdFlag = "1";
            //emp_type_seq = 1;
            CmdStatus = "W";

            // default
            RecordStatus = "W";
            CreatedWhen = DateTime.Now;
        }

		[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
		[DataMember, Column("cmd_seq"),Display(Name = "CmdId", ResourceType = typeof(Resources.PsCommandsResource))]
        public int CmdId { get; set; }

        [CustomRequired]
		[DataMember, Column("cmd_flag"),Display(Name = "CmdFlag", ResourceType = typeof(Resources.PsCommandsResource))]
        public string CmdFlag { get; set; }

		[DataMember, Column("cmd_draft_no"),Display(Name = "CmdDraftNo", ResourceType = typeof(Resources.PsCommandsResource))]
        public string CmdDraftNo { get; set; }

        [CustomRequired]
		[DataMember, Column("cmd_name"),Display(Name = "CmdName", ResourceType = typeof(Resources.PsCommandsResource))]
        public string CmdName { get; set; }

        [DataType(DataType.MultilineText)]
        [Column("cmd_descr", TypeName = "text")]
		[DataMember, Display(Name = "CmdDescr", ResourceType = typeof(Resources.PsCommandsResource))]
        public string CmdDescr { get; set; }

        [CustomRequired]
		[DataMember, Column("cmd_ref_no"),Display(Name = "CmdRefNo", ResourceType = typeof(Resources.PsCommandsResource))]
        public string CmdRefNo { get; set; }

        [CustomRequired]
		[ForeignKey("HrmPsCommandTypes")]
		[DataMember, Column("cmd_type_seq"),Display(Name = "CmdTypeId", ResourceType = typeof(Resources.PsCommandsResource))]
        public Nullable<int> CmdTypeId { get; set; }

        [CustomRequired]
		[ForeignKey("HrmPsEmployeeTypes")]
		[DataMember, Column("emp_type_seq"),Display(Name = "EmpTypeId", ResourceType = typeof(Resources.PsCommandsResource))]
        public Nullable<int> EmpTypeId { get; set; }

		[ForeignKey("HrmMpJobSites")]
		[DataMember, Column("job_site_seq"),Display(Name = "JobSiteId", ResourceType = typeof(Resources.PsCommandsResource))]
        public Nullable<int> JobSiteId { get; set; }

		[ForeignKey("HrmDcPenalty")]
		[DataMember, Column("penalty_seq"),Display(Name = "PenaltyId", ResourceType = typeof(Resources.PsCommandsResource))]
        public Nullable<int> PenaltyId { get; set; }

		[DataMember, Column("cmd_status"),Display(Name = "CmdStatus", ResourceType = typeof(Resources.PsCommandsResource))]
        public string CmdStatus { get; set; }

        [NotMapped()]
		[DataMember, Column("approved_type"),Display(Name = "ApprovedType", ResourceType = typeof(Resources.PsCommandsResource))]
        public Nullable<int> ApprovedType { get; set; }

		[ForeignKey("Approver")]
		[DataMember, Column("approver_seq"),Display(Name = "ApprovedId", ResourceType = typeof(Resources.PsCommandsResource))]
        public Nullable<int> ApproverId { get; set; }

		[DataMember, Column("approved_name"),Display(Name = "ApprovedName", ResourceType = typeof(Resources.PsCommandsResource))]
        public string ApprovedName { get; set; }

		[DataMember, Column("approved_positions"),Display(Name = "ApprovedPositions", ResourceType = typeof(Resources.PsCommandsResource))]
        public string ApprovedPositions { get; set; }

		[DataMember, Column("approved_date"),Display(Name = "ApprovedDate", ResourceType = typeof(Resources.PsCommandsResource))]
        public Nullable<System.DateTime> ApprovedDate { get; set; }

		[DataMember, Column("cmd_rpt_date"),Display(Name = "CmdRptDate", ResourceType = typeof(Resources.PsCommandsResource))]
        public string CmdRptDate { get; set; }

        //[ForeignKey("InvType")]
        //[DataMember, Column("inv_type_seq"),Display(Name = "InvTypeId", ResourceType = typeof(Resources.PsCommandsResource))]
        //public Nullable<int> InvTypeId { get; set; }

		[DataMember, Column("confirm"),Display(Name = "Confirm", ResourceType = typeof(Resources.PsCommandsResource))]
        public Nullable<int> Confirm { get; set; }

		[DataMember, Column("rpt_header"),Display(Name = "RptHeader", ResourceType = typeof(Resources.PsCommandsResource))]
        public string RptHeader { get; set; }

        [DataType(DataType.MultilineText)]
		[DataMember, Column("remarks"),Display(Name = "Remarks", ResourceType = typeof(Resources.PsCommandsResource))]
        public string Remarks { get; set; }

		[DataMember, Column("record_status"),Display(Name = "RecordStatus", ResourceType = typeof(Resources.PsCommandsResource))]
        public string RecordStatus { get; set; }

		[DataMember, Column("created_by"),Display(Name = "CreatedBy", ResourceType = typeof(Resources.PsCommandsResource))]
        public int? CreatedBy { get; set; }

		[DataMember, Column("created_when"),Display(Name = "CreatedWhen", ResourceType = typeof(Resources.PsCommandsResource))]
        public DateTime? CreatedWhen { get; set; }

		[DataMember, Column("updated_by"),Display(Name = "UpdatedBy", ResourceType = typeof(Resources.PsCommandsResource))]
        public int? UpdatedBy { get; set; }

		[DataMember, Column("updated_when"),Display(Name = "UpdatedWhen", ResourceType = typeof(Resources.PsCommandsResource))]
        public DateTime? UpdatedWhen { get; set; }

        [DataMember, Column("changed_back_by_date_end_reach")]
        public virtual bool? ChangedBackByDateEndReach { get; set; }

		[DataMember]
        public virtual ICollection<PsCommandDtls> col_hrm_ps_command_dtls { get; set; }
        


		[DataMember, Display(Name = "HrmPsCommandTypes", ResourceType = typeof(Resources.PsCommandsResource))]
        public virtual PsCommandType HrmPsCommandTypes { get; set; }

		[DataMember, Display(Name = "HrmPsEmployeeTypes", ResourceType = typeof(Resources.PsCommandsResource))]
        public virtual MasEmployeeType HrmPsEmployeeTypes { get; set; }

		[DataMember,Display(Name = "HrmMpJobSites", ResourceType = typeof(Resources.PsCommandsResource))]
        public virtual HRM.JobSite HrmMpJobSites { get; set; }

		[DataMember,Display(Name = "HrmPsEmployees", ResourceType = typeof(Resources.PsCommandsResource))]
        public virtual Employee Approver { get; set; }

		[DataMember, Display(Name = "HrmDcPenalty", ResourceType = typeof(Resources.PsCommandsResource))]
        public virtual DcPenalty HrmDcPenalty { get; set; }
         
        //public virtual ICM.MasInvType InvType { get; set; }

        public virtual PsCommandDtls HrmPsCommandDtls
        {
            get
            {
                var m = new PsCommandDtls();

                return m;
            }
        }


        public PsCommandDtls CreateDetail()
        {
            var m = new HRM.PsCommandDtls();
            m.CmdId = this.CmdId;

            if (this.col_hrm_ps_command_dtls != null)
            {
                //this.col_hrm_ps_command_dtls.Add(m);
            }
            else
            {

            }

            return m;
        }


		[DataMember, Display(Name = "GetFlagName", ResourceType = typeof(Resources.PsCommandsResource))]
        public string GetFlagName
        {
            get
            {
                string strResult = "";

                switch (this.CmdFlag)
                {
                    case "1":
                        strResult = "คำสั่งของหน่วยงาน";
                        break;
                    case "2":
                        strResult = "คำสั่งภายใน";
                        break;
                    case "3":
                        strResult = "คำสั่งจากกระทรวง";
                        break;
                    default:
                        break;
                }

                return strResult;
            }
        }


		[DataMember, Display(Name = "GetCmdStatusName", ResourceType = typeof(Resources.PsCommandsResource))]
        public string GetCmdStatusName
        {
            get
            {
                string strResult = "";

                switch (this.CmdStatus)
                {
                    case "R":
                        strResult = "คำสั่งมีผลบังคับใช้แล้ว";
                        break;
                    default:
                        strResult = "คำสั่งยังไม่มีผลบังคับใช้";
                        break;
                }

                return strResult;
            }
        }

    }
}